package com.tao.mapper;

import com.github.pagehelper.Page;
import com.tao.annotation.AutoFill;
import com.tao.enumeration.OperationType;
import com.tao.pojo.dto.PageSelectProductDto;
import com.tao.pojo.dto.ProductDto;
import com.tao.pojo.entity.Product;
import com.tao.pojo.vo.ProductVo;
import com.tao.pojo.vo.SetmealProductVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ProductMapper {

    void deleteProductMapper(List<Integer> idList);

    @Select("select * from product where category_id=#{categoryId}")
    List<Product> selectByCategoryIdMapper(Integer categoryId);

    @Select("select count(*) from product where category_id=#{categoryId}")
    Integer selectCountByCategoryIdMapper(Integer categoryId);

    @AutoFill(value = OperationType.INSERT)
    void addProductMapper(Product product);

    Page<ProductVo> pageSelectProductMapper(PageSelectProductDto pageSelectProductDto);

    @AutoFill(value = OperationType.UPDATE)
    void updateProductMapper(Product product);

    ProductVo getByIdMapper(Integer id);


    @Update("update product set status =#{status} where id=#{id}")
    void updateStatus(Integer status,Integer id);

    Integer countByStatus( Integer status);

    List<SetmealProductVo> selectProduct(String name);
}
